

[CmdletBinding(PositionalBinding=$false)]
Param(
  [Parameter(Mandatory)]
  $TargetIP,
  [Parameter(Mandatory)]
  $TargetUser,
  [Parameter(Mandatory)]
  $TargetGDBServerPort,
  [Parameter(Mandatory)]
  $TargetSSHServerPort,
  [Parameter(Mandatory)]
  $ExecPath,
  [Parameter(ValueFromRemainingArguments=$true)]
  [string[]]$ParamList=$null
)

$SSHArgs="-o StrictHostKeyChecking=no "

if($TargetSSHServerPort.length -gt 0){
  $SSHArgs=$SSHArgs+"-P ${TargetSSHServerPort} "
}

$SSHArgArr=("${SSHArgs}${TargetUser}@${TargetIP}" -split ' ')

$ExecCMD="gdbserver :${TargetGDBServerPort} ${ExecPath}"
foreach($item in $ParamList){
  $ExecCMD="$ExecCMD $item"
}

$ArgumentList=$SSHArgArr
$ArgumentList+=$ExecCMD


Start-Process ssh -ArgumentList $ArgumentList

